home *** CD-ROM | disk | FTP | other *** search
- Path: eua.ericsson.se!usenet
- From: euahjn@eua.ericsson.se (Henrik Johansson)
- Newsgroups: comp.unix.programmer,comp.lang.c++
- Subject: Re: ?? pointer to function in C++
- Date: 2 Jan 1996 08:39:33 GMT
- Organization: Ericsson Telecom Systems Labs, Stockholm, Sweden
- Distribution: world
- Message-ID: <4car05$hoi@euas20.eua.ericsson.se>
- References: <4c2pm4$69d@enterprise.sct.gu.edu.au>
- Reply-To: euahjn@eua.ericsson.se
- NNTP-Posting-Host: euas31i2c37.eua.ericsson.se
-
- In article <4c2pm4$69d@enterprise.sct.gu.edu.au>, Peter Kese <peter.kese@cit.gu.edu.au> writes:
- > Hi!
- >
- >
- > I am trying to use pointers to C++ class functions (methods), which don't seem
- > to work. My program (class) should look something like this:
- >
- > class myclass {
- > void (*selected)(); // a pointer to a function / method
- > public:
- > void method1(){ ... };
- > void method2(){ ... };
- > myclass(){ // constructor
- > selected_method = method1; // set selected_method (this fails)
- > //or selected_method = method2;
- > };
- > callselected(){ selected_method() } // call the selected_method;
- > };
- >
- >
- > It seems that C++ does not let me obtain a method address:
- >
- > void *someptr = method1 // this doesn't work
- >
- >
- > Can someone help me? (I am working on Unix (SGI, Sun) with CC or gcc)
- >
- > --
- > Peter Kese
- >
-
- See section 18 in the FAQ: Pointers to member functions
-
-
-
-